2_IngredientSeeder.ts ➔ run   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 36
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 36
c 0
b 0
f 0
rs 9.112
cc 2
1
import BaseSeeder from '@ioc:Adonis/Lucid/Seeder'
2
import Merchant from 'App/Models/Merchant'
3
import Ingredient from 'App/Models/Ingredient'
4
import moment from 'moment'
5
6
export default class extends BaseSeeder {
7
  public async run () {
8
    // Write your database queries inside the run method
9
    const merchant = await Merchant.findBy('email', '[email protected]')
10
11
    if (merchant) {
12
      Ingredient.firstOrCreate(
13
          {name: 'Beef'},
14
          {
15
              name: 'Beef',
16
              quantityAvailable: 20000,
17
              quantitySupplied: 20000,
18
              quantityStocked: 20000,
19
              userId: merchant.id,
20
              lastReorderAt: moment().format('YYYY-MM-DD HH:mm:ss')
21
          })
22
23
      Ingredient.firstOrCreate(
24
          {name: 'Cheese'},
25
          {
26
              name: 'Cheese',
27
              quantityAvailable: 5000,
28
              quantitySupplied: 5000,
29
              quantityStocked: 5000,
30
              userId: merchant.id,
31
              lastReorderAt: moment().format('YYYY-MM-DD HH:mm:ss')
32
          })
33
34
      Ingredient.firstOrCreate(
35
          {name: 'Onion'},
36
          {
37
              name: 'Onion',
38
              quantityAvailable: 1000,
39
              quantitySupplied: 1000,
40
              quantityStocked: 1000,
41
              userId: merchant.id,
42
              lastReorderAt: moment().format('YYYY-MM-DD HH:mm:ss')
43
          })
44
    }
45
  }
46
}
47